/*
Created		26/08/2009
Modified		31/03/2011
Project		CIMa Planning
Model			Main
Company		CPIngredientes
Author		RGM
Version		0.1
Database		MS SQL 2000 
*/


DROP TABLE [costs_plants]
Create table [costs_plants]
(
	[plant_version_id] Integer NOT NULL,
	[corn_type_id] Integer NOT NULL,
	[corn_origin_id] Char(1) NOT NULL,
	[cost_element_id] Integer NOT NULL,
	[initial_cost] Decimal(18,4) NOT NULL,
	[initial_tons] Decimal(18,4) NOT NULL,
	[initial_usd] Decimal(18,4) NOT NULL,
	[incoming_cost] Decimal(18,4) NOT NULL,
	[incoming_tons] Decimal(18,4) NOT NULL,
	[incoming_usd] Decimal(18,4) NOT NULL,
	[available_cost] Decimal(18,4) NOT NULL,
	[available_tons] Decimal(18,4) NOT NULL,
	[available_usd] Decimal(18,4) NOT NULL,
	[grind_cost] Decimal(18,4) NOT NULL,
	[grind_tons] Decimal(18,4) NOT NULL,
	[grind_usd] Decimal(18,4) NOT NULL,
	[final_cost] Decimal(18,4) NOT NULL,
	[final_tons] Decimal(18,4) NOT NULL,
	[final_usd] Decimal(18,4) NOT NULL,
Primary Key ([plant_version_id],[corn_type_id],[corn_origin_id],[cost_element_id])
) 
go

Alter table [costs_plants] add  foreign key([cost_element_id]) references [costs_elements] ([cost_element_id])  on update no action on delete no action 
go
Alter table [costs_plants] add  foreign key([plant_version_id]) references [plants_versions] ([plant_version_id])  on update no action on delete cascade 
go
Alter table [costs_plants] add  foreign key([corn_type_id]) references [corns_types] ([corn_type_id])  on update no action on delete no action 
go
Alter table [costs_plants] add  foreign key([corn_origin_id]) references [corns_origins] ([corn_origin_id])  on update cascade on delete no action 
go


Set quoted_identifier on
go



Set quoted_identifier off
go


